<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="myModalLabel">设置标签</h4>
</div>
<div class="modal-body">
    <form>
        <input type="text" id="tag-title" class="form-control" placeholder="Tag Title" value="{% if current_tag %}{{ current_tag.name }}{% endif %}">
    </form>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">我再想想</button>
    <button type="button" class="btn my-btn-primary edit-tag-btn">确认并保存</button>
</div>
<script>
    $('.edit-tag-btn').click(function () {
        var tag_name = $('#tag-title').val();
        if (tag_name) {
            var url = {% if current_tag %}'{{ url_for('tag.tag_edit', tag_id=current_tag.id) }}'{% else %}'{{ url_for('tag.tag_create') }}'{% endif %};
            var data = {
                'tag_name': tag_name,
            };
            $.post(url, data, function (data, status) {
                window.location.reload();
            });
        } else {
            console.log('error');
            return false;
        }
    });
</script>